import os

# os.system('pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple requests==2.24.0')
# 检查库文件，没有就自动安装
# os.system('cls')

import requests

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36',
    'Accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
}

cookies = {
    'cookie': "file_566331_readed=""; file_541606_readed=""; file_1859892_readed=""; file_1159503_readed=""; file_1288455_readed=""; file_1842820_readed=""; file_1288454_readed=""; file_498845_readed=""; file_2010317_readed=""; file_2016323_readed=""; file_2736181_readed=""; file_3190_readed=""; file_3150_readed=""; file_2735675_readed=""; file_145860_readed=""; file_481542_readed=""; file_2007688_readed=""; file_481570_readed=""; file_482057_readed=""; file_2143324_readed=""; file_1425530_readed=""; file_1443959_readed=""; file_1391985_readed=""; file_1334498_readed=""; file_1508341_readed=""; file_2456026_readed=""; file_128617_readed=""; file_2705621_readed=""; file_147113_readed=""; file_138260_readed=""; file_172597_readed=""; file_138563_readed=""; file_1065166_readed=""; file_1763608_readed=""; file_443153_readed=""; file_3198_readed=""; file_1473892_readed=""; file_1719997_readed=""; file_1828387_readed=""; file_2629770_readed=""; file_1838784_readed=""; file_1824963_readed=""; file_1137881_readed=""; file_1506288_readed=""; file_1896793_readed=""; file_482059_readed=""; file_482054_readed=""; file_481597_readed=""; file_525453_readed=""; file_443408_readed=""; file_1106007_readed=""; file_442834_readed=""; file_524006_readed=""; file_2784607_readed=""; file_502705_readed=""; file_3298_readed=""; file_1711835_readed=""; file_1901543_readed=""; file_1187761_readed=""; file_1275611_readed=""; file_542619_readed=""; file_554397_readed=""; file_1534092_readed=""; file_566368_readed=""; file_565926_readed=""; file_538049_readed=""; file_571367_readed=""; file_2017870_readed=""; file_1107706_readed=""; file_524007_readed=""; file_537009_readed=""; file_1138776_readed=""; file_1209728_readed=""; file_2819291_readed=""; file_1197086_readed=""; file_443474_readed=""; file_554395_readed=""; file_568958_readed=""; file_1771004_readed=""; file_487061_readed=""; file_1171228_readed=""; file_1471871_readed=""; file_1701357_readed=""; file_2472759_readed=""; file_2791582_readed=""; file_559054_readed=""; file_555930_readed=""; file_2036618_readed=""; file_555659_readed=""; file_560520_readed=""; file_1818637_readed=""; file_1654261_readed=""; file_1198327_readed=""; file_525452_readed=""; file_1161458_readed=""; file_544405_readed=""; file_443059_readed=""; file_1790638_readed=""; file_1207670_readed=""; file_1961850_readed=""; file_545854_readed=""; file_1515021_readed=""; file_536017_readed=""; file_1189196_readed=""; file_555700_readed=""; file_2717869_readed=""; file_2722495_readed=""; file_541030_readed=""; file_1071205_readed=""; file_537003_readed=""; file_541135_readed=""; file_570490_readed=""; file_482063_readed=""; file_481657_readed=""; file_521050_readed=""; file_1110722_readed=""; file_1849334_readed=""; file_1193135_readed=""; file_1537637_readed=""; file_502694_readed=""; file_502369_readed=""; file_2847328_readed=""; file_2859859_readed=""; file_544406_readed=""; file_524010_readed=""; file_1156526_readed=""; file_1178700_readed=""; file_445939_readed=""; file_1074550_readed=""; file_3271_readed=""; file_482065_readed=""; file_1433429_readed=""; file_444513_readed=""; file_555287_readed=""; file_554389_readed=""; csrftoken=0BBbrHBIVscZg1XQBZxTp307dMDk79kW1hk1LZrUPuBLI7nnxgUziBLM1A0tXv2h; sessionid=rqcv3nw0fi306ofxid77uum9j6t5u8e9; file_439448_readed=""; file_1113167_readed=""; file_525450_readed=""; file_3161_readed=""; file_482068_readed=""; file_524012_readed=""; file_524635_readed=""; file_523646_readed=""; file_524011_readed=""; file_523663_readed=""; file_505886_readed=""; file_1112855_readed=""; file_554391_readed=""; file_1179748_readed="""
# 这里要重新改一下，防止我的cookie泄露我删除了几个字符
# 这里要重新复制为你自己的cookie
}

url_tmp = 'https://www.acwing.com/problem/'
url = url_tmp
cnt_ac = 0
cnt_try = 0

for i in range(1, 72):

    if i != 1:
        url = url_tmp + str(i)

    r = requests.get(url=url, headers=headers, cookies=cookies) # 请求网址

    t_ac = str(r.text).count("已通过这道题目") # 通过对其h5源码进行统计
    t_try = str(r.text).count("尝试过，但未通过这道题目")
    print("第" + str(i) + "页通过了" + str(t_ac) + "道题")

    cnt_ac += t_ac
    cnt_try += t_try

print("\n一共通过了： " + str(cnt_ac))
print("一共尝试了： " + str(cnt_try))
